﻿namespace dotnet_notes.Tools
{
    /// <summary>
    /// 计算工具类
    /// </summary>
    public static class ComputeTool
    {
        /// <summary>
        /// 计算百分比
        /// </summary>
        /// <param name="dividend">被除数</param>
        /// <param name="divisor">除数</param>
        /// <returns>两位小数百分比字符串</returns>
        public static string Percentage(int dividend, int divisor)
        {
            ArgumentOutOfRangeException.ThrowIfZero(divisor, nameof(divisor));

            double percentage = 100.0 * dividend / divisor;
            return $"{percentage:F2}%";
        }
    }
}
